/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author TuanAnh
 */
@Entity
@Table(name = "Room")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Room.findAll", query = "SELECT r FROM Room r"),
    @NamedQuery(name = "Room.findByRoomID", query = "SELECT r FROM Room r WHERE r.roomID = :roomID"),
    @NamedQuery(name = "Room.findByReservation", query = "SELECT r FROM Room r WHERE r.reservation = :reservation"),
    @NamedQuery(name = "Room.findByReceived", query = "SELECT r FROM Room r WHERE r.received = :received")})
public class Room implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "roomID")
    private String roomID;
    @Column(name = "reservation")
    private Boolean reservation;
    @Column(name = "received")
    private Boolean received;
    @ManyToMany(mappedBy = "roomCollection")
    private Collection<ReservationBill> reservationBillCollection;
    @JoinColumn(name = "roomType", referencedColumnName = "roomType")
    @ManyToOne(optional = false)
    private RomType roomType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "roomId")
    private Collection<RentDetail> rentDetailCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "room")
    private Collection<CheckStatusRoom> checkStatusRoomCollection;

    public Room() {
    }

    public Room(String roomID) {
        this.roomID = roomID;
    }

    public String getRoomID() {
        return roomID;
    }

    public void setRoomID(String roomID) {
        this.roomID = roomID;
    }

    public Boolean getReservation() {
        return reservation;
    }

    public void setReservation(Boolean reservation) {
        this.reservation = reservation;
    }

    public Boolean getReceived() {
        return received;
    }

    public void setReceived(Boolean received) {
        this.received = received;
    }

    @XmlTransient
    public Collection<ReservationBill> getReservationBillCollection() {
        return reservationBillCollection;
    }

    public void setReservationBillCollection(Collection<ReservationBill> reservationBillCollection) {
        this.reservationBillCollection = reservationBillCollection;
    }

    public RomType getRoomType() {
        return roomType;
    }

    public void setRoomType(RomType roomType) {
        this.roomType = roomType;
    }

    @XmlTransient
    public Collection<RentDetail> getRentDetailCollection() {
        return rentDetailCollection;
    }

    public void setRentDetailCollection(Collection<RentDetail> rentDetailCollection) {
        this.rentDetailCollection = rentDetailCollection;
    }

    @XmlTransient
    public Collection<CheckStatusRoom> getCheckStatusRoomCollection() {
        return checkStatusRoomCollection;
    }

    public void setCheckStatusRoomCollection(Collection<CheckStatusRoom> checkStatusRoomCollection) {
        this.checkStatusRoomCollection = checkStatusRoomCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roomID != null ? roomID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Room)) {
            return false;
        }
        Room other = (Room) object;
        if ((this.roomID == null && other.roomID != null) || (this.roomID != null && !this.roomID.equals(other.roomID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.fpt.entity.Room[ roomID=" + roomID + " ]";
    }
    
}
